<?php
require('includes/application_top.php');
$shipping_company = $_POST["shipping_company"];
function getDatesBetween2Dates($startTime, $endTime) {
	$day = 86400;
	$formatSQL = 'Y-m-d';
	$formatShow = 'd/m/Y';
	$startTime = strtotime($startTime);
	$endTime = strtotime($endTime);
	$numDays = round(($endTime - $startTime) / $day) + 1;
	$days = array();

	for ($i = 0; $i < $numDays; $i++) {
		$days[] = array('sql' => date($formatSQL, ($startTime + ($i * $day))), 'show' => date($formatShow, ($startTime + ($i * $day))));
	}

	return $days;
} 
?>

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
<script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
<script type="text/javascript">
  <!--
  function init()
  {
    cssjsmenu('navbar');
    if (document.getElementById)
    {
      var kill = document.getElementById('hoverJS');
      kill.disabled = true;
    }
  }
  // -->
</script>
</head>
<body onLoad="init()">
<div id="spiffycalendar" class="text"></div>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
  <tr>
<!-- body_text //-->

    <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
      <tr>
        <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
          <tr>
            <td class="pageHeading">Shipping Costs Report</td>
            <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td>
          <form style="margin-left: 20px;" name="cash_form" action="shipping_report.php" method="POST">
            <span>Shipping Company:</span>
            <select name="shipping_company">
                <option value="1" <?php echo($shipping_company === "1" ? "selected" : ""); ?>>CTT Expresso</option>
                <option value="2" <?php echo($shipping_company === "2" ? "selected" : ""); ?>>NACEX</option>
                <option value="3" <?php echo($shipping_company === "3" ? "selected" : ""); ?>>SEUR</option>
            </select>
            <script language="javascript">
                    var StartDate = new ctlSpiffyCalendarBox("StartDate", "cash_form", "start", "btnDate1", "<?php echo isset($_POST['start']) ? $_POST['start'] : date('m/d/Y'); ?>", scBTNMODE_CUSTOMBLUE);
                    var EndDate = new ctlSpiffyCalendarBox("EndDate", "cash_form", "end", "btnDate2", "<?php echo isset($_POST['end']) ? $_POST['end'] : date('m/d/Y'); ?>", scBTNMODE_CUSTOMBLUE);
            </script>
            <span>Inicio</span>
            <span><script language="javascript">StartDate.writeControl(); StartDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></span>
            <span>Fim</span>
            <span><script language="javascript">EndDate.writeControl(); EndDate.dateFormat="<?php echo DATE_FORMAT_SPIFFYCAL; ?>";</script></span>
            <input type="submit" value="Generate">
          </form>
        </td>
      </tr>
    </table></td>

<!-- body_text_eof //-->
  </tr>
  <td>
<?php
    if($shipping_company === "3")
        require('includes/templates/tpl_shipping_report_seur.php');
    else if($shipping_company === "1")
        require('includes/templates/tpl_shipping_report_ctt.php');
?>
  </td>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php
require(DIR_WS_INCLUDES . 'application_bottom.php');

?>